#include "PrototypeMidi.hpp"
#include "Keyboard.hpp"

void PrototypeMidi::Run()
{
    if (key[KEY_1])
        mpSong->Play();
    else if (key[KEY_2])
       mpSong->Pause();
    else if (key[KEY_3])
        mpSong->Resume();
    else if (key[KEY_4])
        mpSong->Stop();
    else if (key[KEY_5])
    {
    }
    else if (key[KEY_6])
    {
    }
}

//////////////////////////////////////////////////////////////////////////
void PrototypeMidi::Render(BITMAP* aBuffer)
{
    textout_ex(aBuffer, font, "1: Play", 10, 30, (255,255,255), NULL);
    textout_ex(aBuffer, font, "2: Pause", 10, 50, (255,255,255), NULL);
    textout_ex(aBuffer, font, "3: Resume", 10, 70, (255,255,255), NULL);
    textout_ex(aBuffer, font, "4: Stop", 10, 90, (255,255,255), NULL);
    if (mpSong->IsPaused())
        textout_ex(aBuffer, font, "Song paused", 10, 120, (255,255,255), NULL);
    else if (mpSong->IsPlaying())
        textout_ex(aBuffer, font, "Song playing", 10, 120, (255,255,255), NULL);
    else if (mpSong->IsReady())
        textout_ex(aBuffer, font, "Song ready", 10, 120, (255,255,255), NULL);
}

//////////////////////////////////////////////////////////////////////////
void PrototypeMidi::Init()
{
    mpSong.reset( new Midi("../Midi/FF7aerit.mid") );
    ASSERT( mpSong->IsReady() );
}

//////////////////////////////////////////////////////////////////////////
void PrototypeMidi::DeInit()
{
    mpSong.reset();
}